﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace WcfContrib.Extensions.OutputControllers
{
    class ConsoleOutputController : OutputControllerBase
    {
        #region IOutputController Members
        protected override void OnLoadState()
        {
        }

        protected override void OnOutputMessage(string message)
        {
            ConsoleColor? color = null;
            TryGetArgument<ConsoleColor>(OutputArgument.ConsoleColor, out color);

            ConsoleColor orgColor = Console.ForegroundColor;
            if (color.HasValue)
            {
                Console.ForegroundColor = color.Value;
            }

            Console.WriteLine(message);

            if (color.HasValue)
            {
                Console.ForegroundColor = orgColor;
            }
        }
        #endregion
    }
}
